<html>
<head>
<title>JEmu</title>

<style type="text/css">
	a, p, th, input, div {
		font-family: "verdana", helvetica;
		font-size: 8pt;
	}
	td {
		font-family: "lucida console", monospace;
		font-size: 8pt;
	}
	td.memory {
		text-align: center;
	}
	table {
		border-collapse: collapse;
		empty-cells: show;
	}

</style>

<script type="text/javascript">

function show_memory()
{
	if(document.getElementById('display_memory').checked == true)
		document.getElementById('memory').style.display = 'block';
	else
		document.getElementById('memory').style.display = 'none';
	document.getElementById('JEmu').rebuildDebugger(-3);
}

function show_cpu()
{
	if(document.getElementById('display_cpu').checked == true)
		document.getElementById('cpu').style.display = 'block';
	else
		document.getElementById('cpu').style.display = 'none';
	document.getElementById('JEmu').rebuildDebugger(-1);
}

function show_video()
{
	if(document.getElementById('display_video').checked == true)
		document.getElementById('video').style.display = 'block';
	else
		document.getElementById('video').style.display = 'none';
	document.getElementById('JEmu').rebuildDebugger(-2);
}

function show_device(n)
{
	if(document.getElementById('display_device_' + n).checked == true)
		document.getElementById('dev' + n).style.display = 'block';
	else
		document.getElementById('dev' + n).style.display = 'none';
	document.getElementById('JEmu').rebuildDebugger(n);
}

function debug_line(decolor, color)
{
	c = document.getElementById('p' + color);
	d = document.getElementById('p' + decolor);
	for(var i=1; i<=4; i++)
	{
		if(color != -1)
			c.cells[i].style.backgroundColor = "yellow";
		if(d)
			d.cells[i].style.backgroundColor = "transparent";
	}
}

function set_breakpoint(row, pos)
{
	if(row.style.backgroundColor == "red")
	{
		row.style.backgroundColor = "transparent";
		document.getElementById('JEmu').removeBreakpoint(pos);
	}
	else
	{
		row.style.backgroundColor = "red";
		document.getElementById('JEmu').addBreakpoint(pos);
	}
}

function use_debugger()
{
	if(document.getElementById('use_debugger').checked == true)
		document.getElementById('debuggers').style.display = 'block';
	else
		document.getElementById('debuggers').style.display = 'none';
	document.getElementById('JEmu').setDebugging(document.getElementById('use_debugger').checked);
}

</script>

</head>
<body>
	<table>
		<tr><td><applet id="JEmu" code="Atari2600" codebase="classes/" 
				width=320 height=192 mayscript></applet></td>
			<td>
				<!-- Options -->
				<input type="checkbox" id="use_debugger" onclick="use_debugger()">Use debugger (advanced)
			</td>
		</tr>
	</table>

<!-- Debuggers -->
<span id="debuggers" style="display: none;">
<p><b>Debuggers:</b>&nbsp;
	<span id="cpu_bt"><input type="checkbox" id="display_cpu" onclick="show_cpu()"><span id="cpu_name">CPU</span></span>
	<span id="video_bt"><input type="checkbox" id="display_video" onclick="show_video()"><span id="video_name">Video</span></span>
	<span id="devices"></span>
	<span id="memory_bt"><input type="checkbox" id="display_memory" onclick="show_memory()">Memory</span>
</p>
<p>
	<input id="run" type="button" value="Run" onclick="document.getElementById('JEmu').runButton();">
	<input id="step" type="button" value="Step" onclick="document.getElementById('JEmu').stepButton();">
	<input id="next_scanline" type="button" value="Next Scanline" onclick="document.getElementById('JEmu').nextScanlineButton();">
	<input id="next_frame" type="button" value="Next Frame" onclick="document.getElementById('JEmu').nextFrameButton();">
</p>
</span>

<!-- ROMS -->
<a onclick="document.getElementById('JEmu').loadROM('rom/atari2600/simple.bin');">Simple</a>&nbsp;
<a onclick="document.getElementById('JEmu').loadROM('rom/atari2600/dot.bin');">Dot</a>&nbsp;
<a onclick="document.getElementById('JEmu').loadROM('rom/atari2600/kernel1.bin');">Kernel1</a>&nbsp;
<a onclick="document.getElementById('JEmu').loadROM('rom/atari2600/kernel11.bin');">Kernel11</a>&nbsp;
<a onclick="document.getElementById('JEmu').loadROM('rom/atari2600/kernel15.bin');">Kernel15</a>&nbsp;
<a onclick="document.getElementById('JEmu').loadROM('rom/atari2600/joy.bin');">Joy</a>&nbsp;
<a onclick="document.getElementById('JEmu').loadROM('rom/atari2600/peace.bin');">Peace</a>&nbsp;
<a onclick="document.getElementById('JEmu').loadROM('rom/atari2600/happy.bin');">Happy</a>&nbsp;
<a onclick="document.getElementById('JEmu').loadROM('rom/atari2600/pitfall.bin');">Pitfall</a>&nbsp;
<a onclick="document.getElementById('JEmu').loadROM('rom/atari2600/tennis.bin');">Tennis</a>&nbsp;
<a onclick="document.getElementById('JEmu').loadROM('rom/atari2600/freeway.bin');">Freeway</a>&nbsp;
<a onclick="document.getElementById('JEmu').loadROM('rom/atari2600/fishdrby.bin');">Fishing</a>&nbsp;
<a onclick="document.getElementById('JEmu').loadROM('rom/atari2600/timer.bin');">Timer</a>&nbsp;

<!-- CPU Debugger -->
<table border='1'><tr>
<td valign='top'>
<div id="cpu" style="display: none;">
	<p>Initial position: $<input id="cpu_pos" type="text" size=4 maxlength=4 value="0000" onchange="document.getElementById('JEmu').rebuildDebugger(-1)"></p>
	<div id="cpu_table"></div>
</div>
</td>

<!-- Video debugger -->
<td valign='top'>
<div id="video" style="display: none;">
	<div id="video_table"></div>
</div>
</td></tr>

<!-- Device Debuggers -->
<div id="dev0" style="display: none;">
<td valign='top'>
	<div id="dev_table_0"></div>
</div>
</td>
<td valign='top'>
<div id="dev1" style="display: none;">
	<div id="dev_table_1"></div>
</div>
</td>
<td valign='top'>
<div id="dev2" style="display: none;">
	<div id="dev_table_2"></div>
</div>
</td>
<td valign='top'>
<div id="dev3" style="display: none;">
	<div id="dev_table_3"></div>
</div>
</td>
</tr></table>

<!-- Memory Debugger -->
<div id="memory" style="display: none;">
	<hr>
	<p>Initial position: $<input id="memory_pos" type="text" size=4 maxlength=4 value="0000" onchange="document.getElementById('JEmu').rebuildDebugger(-3)"></p>
	<div id="memory_table"></div>
</div>

</body>
</html>
